package com.maxatime.service.impl;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.maxatime.dao.ExamSubjectMapper;
import com.maxatime.pojo.entity.ExamSubject;
import com.maxatime.service.ExamSubjectService;
import com.maxatime.util.SerialNumberUtil;

@Service
public class ExamSubjectServiceImpl implements ExamSubjectService{
	
	@Autowired
	ExamSubjectMapper examSubjectMapper;
	@Override
	public int deleteByPrimaryKey(Integer pkId) {
		// TODO Auto-generated method stub
		return examSubjectMapper.deleteByPrimaryKey(pkId);
	}

	@Override
	public int insert(ExamSubject record) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int insertSelective(ExamSubject record) {
		// TODO Auto-generated method stub
		ExamSubject examSubject =  new ExamSubject();
		BeanUtils.copyProperties(record, examSubject);
		Date d = new Date();
		examSubject.setExamSubjectId(String.valueOf(SerialNumberUtil.getRandomNum()));
		examSubject.setExamStartTime(d);
		examSubject.setExamEndTime(d);
		examSubject.setDeleteFlag("0");
		examSubject.setCreateDate(d);
		examSubject.setUpdateDate(d);
		examSubjectMapper.insertSelective(examSubject);
		return 0;
	}

	@Override
	public ExamSubject selectByPrimaryKey(Integer pkId) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int updateByPrimaryKeySelective(ExamSubject record) {
		// TODO Auto-generated method stub
		ExamSubject examSubject = new ExamSubject();
		BeanUtils.copyProperties(record, examSubject);
		Date d = new Date();
		examSubject.setUpdateDate(d);
		examSubjectMapper.updateByPrimaryKeySelective(examSubject);
		return 0;
	}

	@Override
	public int updateByPrimaryKey(ExamSubject record) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public Map<String, Object> list(ExamSubject examSubject) {
		// TODO Auto-generated method stub
		PageHelper.startPage(examSubject.getPageNum(), examSubject.getPageSize());
		List<ExamSubject> examSubject1 = examSubjectMapper.list(examSubject);
		PageInfo<ExamSubject> pageInfo = new PageInfo<ExamSubject>(examSubject1);
		Map<String, Object> m = new HashMap<>();
		m.put("examSubject1", examSubject1);
		m.put("pageInfo", pageInfo);
		return m;
	}

	@Override
	public ExamSubject find(int pkId) {
		// TODO Auto-generated method stub
		return examSubjectMapper.find(pkId);
	}

}
